package com.nexus.service.sys.service.mapstruct;

import com.nexus.core.service.mapstruct.BaseConverter;
import com.nexus.core.sys.entity.SysPost;
import com.nexus.core.sys.dto.SysPostDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * SysPostWrapper
 *
 * @author 路正宁
 * @version 2023-03-16
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = {})
public interface SysPostWrapper extends BaseConverter<SysPost,SysPostDTO> {

    SysPostWrapper INSTANCE = Mappers.getMapper(SysPostWrapper.class);

    @Mappings({
            @Mapping(source = "org.id", target = "org"),
            @Mapping(source = "createBy.id", target = "createBy"),
            @Mapping(source = "updateBy.id", target = "updateBy")})
    SysPost toEntity(SysPostDTO dto);

    @Mappings({
            @Mapping(source = "org", target = "org.id"),
            @Mapping(source = "createBy", target = "createBy.id"),
            @Mapping(source = "updateBy", target = "updateBy.id")})
    SysPostDTO toDTO(SysPost entity);
}

